﻿using System;
using System.Windows.Forms;
using SystemCustomers.DBUtils;

namespace SystemCustomers.ManageServiceToCustomers
{
    class ManageViewingServiceToCustomer
    {

        public DialogResult editRowToolStripMenuItem(DataGridViewRow dr)
        {
            string compantId = dr.Cells["IdCompany_Services"].Value.ToString();
            string serviceId = dr.Cells["idservice_Services_Company"].Value.ToString();
            string companyName = dr.Cells["CompanyNameSTC"].Value.ToString();
            string serviceName = dr.Cells["serviceName_Service_Company"].Value.ToString();
            bool paid = Convert.ToBoolean(dr.Cells["paidServiceCompany"].Value.ToString());
            using (
                ManageServiceToCustomer editData = new ManageServiceToCustomer(companyName, serviceName, compantId,
                                                                               serviceId,
                                                                               DateTime.Parse(
                                                                                   dr.Cells["startdate"].Value.ToString()),
                                                                               DateTime.Parse(
                                                                                   dr.Cells["enddate"].Value.ToString()),
                                                                               dr.Cells["price"].Value.ToString(),
                                                                               dr.Cells["priceCost"].Value.ToString(),paid))
            {
                editData.btnAdd.Visible = false;
               return editData.ShowDialog();
            }
        }

        public void deleteRowToolStripMenuItem(DataGridViewRow dr)
        {
            string companyId = dr.Cells["IdCompany_Services"].Value.ToString();
            string serviceId = dr.Cells["idservice_Services_Company"].Value.ToString();
            SingletonManagerDb.Instance.DeleteRowServiceToCompany(companyId, serviceId);
        }

    }
  
}
